#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// #include <math.h>
// #include "Binary_conversion_helper.h"
// #include "Heap_memory_management_helper.h"
#include "time_helper.h"
//#include "test_func.c"


void psum1(float a[],float p[],long n) {
    long i;
    p[0] = a[0];
    for (i = 1; i < n; i++) {
        p[i] = p[i - 1] + a[i];
    }
}

void psum2(float a[],float p[],long n) {
    long i;
    p[0] = a[0];
    for (i = 1; i < n-1; i+=2) {
        float mid_val = p[i-1] + a[i];
        p[i] = mid_val;
        p[i+1] = mid_val + a[i+1];
    }
    if(i < n) p[i] = p[i-1] + a[i];
}

int N=2000;

void fun1(){
    float a[N];
    float b[N];
    for(int i=1;i<=N;i++){
        a[i] = i;
    }
    psum1(a,b,N);
}

void fun2(){
    float a[N];
    float b[N];
    for(int i=1;i<=N;i++){
        a[i] = i;
    }
    psum2(a,b,N);
}

int main(int argc, char *argv[]) {
    void (*fptr_1)(void) = fun1;
    void (*fptr_2)(void) = fun2;

    time_difference_Win(fptr_1);
    time_difference_Win(fptr_2);



    get_format_time();


    //system("pause");
    return 0;
}



/*
gcc -E main.c -o main.i;gcc -S -Og main.i -o main.s;gcc -c -O1 main.s -o main.o;gcc -O1 main.o -o main.exe

# 预处理
gcc -E main.c -o main.i

# 编译
gcc -S -Og main.i -o main.s

# 汇编
gcc -c -O1 main.s -o main.o

# 链接
gcc -O1 main.o -o main.exe
*/